package com.ithaime.rabbitmq.consumer.utils;


import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

public class ConnectionUtils {

    public static Connection getConnection() throws Exception{

        //创建连接工程
        ConnectionFactory factory = new ConnectionFactory();
        //设置参数
        factory.setHost("127.0.0.1");  //默认 localhost
        factory.setPort(5672); // 默认 5672
        factory.setVirtualHost("/");
        factory.setUsername("guest");
        factory.setPassword("guest");

        return factory.newConnection();
    }
}
